package com.dailyblue.java.spring.cloud.alibaba.config.controller;

import com.dailyblue.java.spring.cloud.example.commons.util.JsonResult;
import com.dailyblue.java.spring.cloud.example.commons.util.ResultTool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {
    @Value("${my.user.name}")
    private String name;
    @Value("${my.user.age}")
    private Integer age;
    @Value("${gaofei.user.name}")
    private String gaofeiName;
    @Value("${gaofei.user.age}")
    private String gaofeiAge;
    @Value("${gaofei.user.sex}")
    private String gaofeiSex;
    @Value("${gaofei.user.address}")
    private String gaofeiAddress;

    @GetMapping("/a")
    public JsonResult a() {
        return ResultTool.success(name + "," + age);
    }

    @GetMapping("/b")
    public JsonResult b() {
        return ResultTool.success(gaofeiName + "," + gaofeiAge + "," + gaofeiAddress + "," + gaofeiSex);
    }
}
